<!--
 * @Author: taoke
 * @Date: 2022-05-05 10:11:40
 * @LastEditors: taoke
 * @LastEditTime: 2022-05-11 16:58:10
 * @Description: 
 * @FilePath: \yunying-sys-cli4\src\components\partner\order\topSearch.vue
-->
<template>
  <div id="mTopSearch">
    <div class="search-box">
      <el-form
        ref="ruleForm"
        :inline="true"
        :model="formInline"
        class="demo-form-inline"
      >
        <el-form-item label="手机号" prop="consigneeMobile">
          <el-input
            v-model="formInline.consigneeMobile"
            placeholder="请输入手机号"
            clearable
          >
          </el-input>
        </el-form-item>
        <el-form-item label="大鹏号" prop="dpAccount">
          <el-input
            v-model="formInline.dpAccount"
            placeholder="大鹏号查找"
            clearable
          >
          </el-input>
        </el-form-item>
        <el-form-item label="快递号" prop="expressNumber">
          <el-input
            v-model="formInline.expressNumber"
            placeholder="请输入快递号"
            clearable
          >
          </el-input>
        </el-form-item>
        <el-form-item label="订单时间" prop="orderTime">
          <el-date-picker
            v-model="formInline.orderTime"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            value-format="yyyy-MM-dd HH:mm:ss"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="商品名称" prop="prizeName">
          <el-input
            v-model="formInline.prizeName"
            placeholder="请输入商品名称"
            clearable
          >
          </el-input>
        </el-form-item>
        <el-form-item label="奖品类型" prop="prizeType">
          <el-select
            v-model="formInline.prizeType"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="item in prizeTypeOptions"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发放状态" prop="status">
          <el-select v-model="formInline.status" placeholder="请选择" clearable>
            <el-option
              v-for="item in statusSelectOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item class="s-btn">
          <el-button
            type="success"
            icon="el-icon-search"
            @click="toSearch('ruleForm')"
          >
            查询
          </el-button>
          <el-button type="success" plain @click="reset">
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { sysNormalDisable } from '@utils/dictionariesFunc'
import { statusSelectOptions } from '@/components/partner/types/selectOptions'
export default {
  name: 'mTopSearch',
  msg: '合伙人订单列表-顶部搜索',
  props: {
    formInline: {
      type: Object,
      default: function() {
        return {
          consigneeMobile: undefined, //手机号
          dpAccount: undefined, // 大鹏号
          expressNumber: undefined, // 快递号
          orderTime: [],
          startTime: undefined, // 开始日期
          endTime: undefined, // 结束日期
          prizeName: undefined, // 商品名称
          status: undefined, // 快递状态
          prizeType: '', // 商品类型
          status: '' // 发放状态
        }
      }
    }
  },
  data() {
    return {
      prizeTypeOptions: [
        {
          dictLabel: '全部',
          dictValue: ''
        }
      ],
      statusSelectOptions
    }
  },
  created() {
    this.getDict()
  },
  methods: {
    async getDict() {
      // 获取奖品类型
      const prizeTypeOptions = await sysNormalDisable(
        'partner_order_prize_type'
      )
      this.prizeTypeOptions = [...this.prizeTypeOptions, ...prizeTypeOptions]
    },
    /* 搜索 */
    toSearch(formName) {
      this.$parent.searchParams.pageNum = 1
      this.$emit('toSearch')
    },
    /* 重置 */
    reset() {
      this.$refs['ruleForm'].resetFields()
      this.formInline.orderTime = []
    }
  },
  watch: {
    'formInline.orderTime': {
      handler(newVal, oldVal) {
        if (newVal && newVal.length > 1) {
          this.formInline.startTime = newVal[0]
          this.formInline.endTime = newVal[1]
        } else {
          this.formInline.startTime = ''
          this.formInline.endTime = ''
        }
      },
      deep: true
    }
  }
}
</script>

<style lang="less">
#mTopSearch {
  .long-input {
    .el-input--suffix {
      width: 130px !important;
    }
  }
}
</style>
